/*
 * @Description:
 * @Author: xinqiao lxq1990.0716@qq.com
 * @Date: 2023-07-19
 * @LastEditors: xinqiao lxq1990.0716@qq.com
 * @LastEditTime: 2025-06-12
 */
import type { App } from 'vue'
import type { RouteRecordRaw } from 'vue-router'
import { createRouter, createWebHistory } from 'vue-router'

import { mainRoutes } from './routes/modules'
import { errorRoutes } from './routes/sysModules'

export const routes: Array<RouteRecordRaw> = [...errorRoutes, ...mainRoutes]

export const router = createRouter({
  history: createWebHistory(import.meta.env.VITE_BASE_ROUTE_PATH),
  routes,
  scrollBehavior: () => ({ left: 0, top: 0 }),
})

export async function setupRouter(app: App) {
  // 创建路由守卫
  //createRouterGuards(router, whiteNameList)

  app.use(router)

  // 路由准备就绪后挂载APP实例
  await router.isReady()
}

export default router
